import cmsparse.TextUtils;

import java.util.regex.Pattern;

/**
 * Created by wangxingsheng on 2019/6/27.
 */
public class RegexTest {
    public static void main(String[] args) {
        System.out.println("-----");

        String regex = "(\\d{4})(?=\\d)";
        String text = "22222222";
        System.out.println(text.replaceAll(regex, "$1 "));


        String regex1 = "(\\d+)";
        String text1 = "22222222";
        System.out.println(Pattern.matches(regex1, text1));

        String regex2 = "x";
        String text2 = "asdfasdfAx12";
        System.out.println(Pattern.matches(regex2, text2));

        CharSequence source = "同";
        if (!TextUtils.isEmpty(source) && Pattern.matches(regex2, source)) {
            System.out.println("么么么么么么");
        }
    }
}
